Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Polyhedra

A polyhedron is a polyhedral primitive, all of whose faces are triangular. The faces of a polyhedron are defined indirectly, using indices into an array of vertices. This indirection makes it easy for faces to share vertices and attribute sets, thereby reducing the memory required to define the polyhedron and reducing the time required to render the polyhedron. Figure 27 shows a polyhedron.

Figure 27 A polyhedron

It's possible to render non-triangular faces by controlling which edges are drawn. For example, you can make a quadrilateral face by defining two triangular faces with a common edge that is not rendered.

You define an individual face of a polyhedron in part by specifying three indexed vertices. An indexed vertex is a three-dimensional vertex specified by its index into an array of three-dimensional points, together with an attribute set. An indexed vertex is defined using the TQ3IndexedVertex3D data type.

typedef struct TQ3IndexedVertex3D {
    unsigned long                       pointIndex;
    TQ3AttributeSet                     attributeSet;
} TQ3IndexedVertex3D;
pointIndex
An index into an array of three-dimensional points. (The array is specified by the points field of the TQ3PolyhedronData data structure.)
attributeSet
A set of attributes for the vertex. The value in this field is NULL if no vertex attributes are defined.

A polyhedron edge data structure specifies information about an edge of a polyhedron. A polyhedron edge data structure is defined by the TQ3PolyhedronEdgeData data structure.

typedef struct TQ3PolyhedronEdgeData {
    unsigned long                       pointIndices[2];
    unsigned long                       triangleIndices[2];
    TQ3AttributeSet                     edgeAttributeSet;
} TQ3PolyhedronEdgeData;
pointIndices
Two indices into an array of three-dimensional points. (The array is specified by the points field of the TQ3PolyhedronData data structure.) These two points define the endpoints of the edge.
triangleIndices
Two indices into an array of polyhedron triangle data structures, which contain information about the faces in the polyhedron. (The array is specified by the triangles field of the TQ3PolyhedronData data structure.) These two triangles define the two faces that contain the edge. When an edge abuts only one face (that is, when the edge is on a boundary of the polyhedron), you can use the constant kQ3ArrayIndexNULL as the face index for the side of the edge that has no face attached to it.
edgeAttributeSet
A set of attributes for the edge. The value in this field is NULL if no edge attributes are defined.

A polyhedron triangle data structure specifies information about a triangular face of a polyhedron. A polyhedron triangle data structure is defined by the TQ3PolyhedronTriangleData data type.

typedef struct TQ3PolyhedronTriangleData {
    TQ3IndexedVertex3D                  vertices[3];
    TQ3PolyhedronEdge                   edgeFlag;
    TQ3AttributeSet                     triangleAttributeSet;
} TQ3PolyhedronTriangleData;
vertices
An array specifying the three indexed vertices that define the triangle.
edgeFlag
A triangle edge flag. The bits in this field indicate which edges of a polyhedral triangle are to be rendered. See "Polyhedron Edge Masks" for a list of the available edge flags. Note that a renderer ignores edge flags if an explicit list of polyhedron edges is available.
triangleAttributeSet
A set of attributes for the triangle. The value in this field is NULL if no triangle attributes are defined.
Finally, a polyhedron is defined by the TQ3PolyhedronData data type.
 
typedef struct TQ3PolyhedronData {
    unsigned long                       numPoints;
    TQ3Point3D                          *points;
    unsigned long                       numEdges;
    TQ3PolyhedronEdgeData               *edges;
    unsigned long                       numTriangles;
    TQ3PolyhedronTriangleData           *triangles;
    TQ3AttributeSet                     polyhedronAttributeSet;
} TQ3PolyhedronData;
numPoints
The number of points in the polyhedron.
points
A pointer to the array of points in the polyhedron.
numEdges
The number of edges in the polyhedron. Set this field to 0 if you do not want to specify any edges.
edges
A pointer to an array of polyhedron edge data structures, which contain information about the edges in the polyhedron. Set this field to NULL if you do not want to specify any edges.
numTriangles
The number of triangles (that is, faces) in the polyhedron.
triangles
A pointer to an array of polyhedron triangle data structures, which contain information about the faces in the polyhedron.
polyhedronAttributeSet
A set of attributes for the entire polyhedron. The value in this field is NULL if no polyhedron attributes are defined.

© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |